package com.cvo.scrumtoolkit.client.pannels;

import com.cvo.scrumtoolkit.client.controller.ControllerImpl;
import com.cvo.scrumtoolkit.client.controller.View;
import com.cvo.scrumtoolkit.client.entities.LoadedProject;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class MenuPanel extends Composite  {

	private static MenuPanelUiBinder uiBinder = GWT
			.create(MenuPanelUiBinder.class);

	interface MenuPanelUiBinder extends UiBinder<Widget, MenuPanel> {
	}

	public MenuPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}
	
	@UiHandler("home")
	 void handleHome(ClickEvent e) {
		try{
			 ControllerImpl.getController().changeView(View.HOME, null, null);
		}catch (Exception ex) {
			// TODO: handle exception
		}
	}

	@UiHandler("newproject")
	 void handleNewProject(ClickEvent e){
		try{
			ControllerImpl.getController().changeView(View.NEWPROJECT, null, null);
		}catch (Exception ex) {
			// TODO: handle exception
		}
	}
	
	@UiHandler("productbacklog")
	 void handleProductbacklog(ClickEvent e) {
		try {
			//controle dat al een project geladen is met die bepaalde klasse LoadedProject
			if(LoadedProject.getLoadedProject().getProjectId() != null){
				ControllerImpl.getController().changeView(View.PROJECTBACKLOG, LoadedProject.getLoadedProject().getProjectId(), null);
			}
		}catch (Exception ex) {
			// TODO: handle exception
		}			
	}
	
	@UiHandler("sprintbacklog")
	 void handleSprintbacklog(ClickEvent e) {
		try{
			if(LoadedProject.getLoadedProject().getProjectId() != null){
			ControllerImpl.getController().changeView(View.SPRINTBLACKLOG, LoadedProject.getLoadedProject().getProjectId(), null);
			}
		}catch (Exception ex) {
			// TODO: handle exception
		}
	}
	
	@UiHandler("scrumboard")
	 void handleScrumboard(ClickEvent e) {
		
	}
	
	@UiHandler("burndownchart")
	 void handleBurndownChart(ClickEvent e) {}

	








}
